<div class="alert alert-success"><span class="glyphicon glyphicon-info-sign"></span> 对用户发送消息包含关键词的回复。一个规则可以对应多个关键词，匹配其中一个关键词即进行自动回复。</div>
<form action="" class="form-horizontal" role="form">

	<div class="form-group">
		<label class="col-sm-2 control-label">规则名</label>
		<div class="col-sm-3">
			<input type="text" class="form-control" name="rule" placeholder="给此条关键字回复设置一个规则名，用来区分" datatype="*" value="{$keywordReply.rule}"/>
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-2 control-label">关键词</label>
		<div class="col-sm-3">
			<input type="text" class="form-control" name="keyword" placeholder="关键词列表，多个使用英文逗号,隔开" value="{$keywordReply.keyword}"/>
			<span class="label label-info">关键词列表，多个使用英文逗号,隔开</span>
		</div>
	</div>

	<div class="form-group">
	    <label class="col-sm-2 control-label">自动回复类型</label>
	    <div class="col-sm-2">
	    	<select class="form-control" id="type-select" name="type" datatype="*">{$keywordReply.type}</select>
	    </div>
	</div>
	
	<!-- 文本 -->
	<div class="form-group" id="type-text">
		<label class="col-sm-2 control-label">自动回复内容</label>
		<div class="col-sm-4">
			<textarea class="form-control" name="text" rows="5" id="txtContent">{$keywordReply.text}</textarea>
		</div>
	</div>
	
	<!-- 图文 -->
	<div class="form-group" id="type-news">
		<label class="col-sm-2 control-label">自动回复内容</label>
		<div class="col-sm-5">
			<div id="news-result">
				<ul class="news-edit-lists">
				</ul>
			</div>
		</div>
	</div>
	
	<div class="form-group">
		<div class="col-sm-offset-2 col-sm-8">
			<a class="btn btn-default" onclick="javascript:history.go(-1)">返回上页</a>
			<a class="btn btn-default" onclick="self.location=document.referrer">返回上页并刷新</a>
			<input type="hidden" name="id" value="{$keywordReply.id}"/>
			<input type="hidden" name="news" id="news-id" value="" />
			<button type="submit" class="btn btn-primary submit" data-loading-txt="提交中，请稍后……" data-ajax-url="__CONTROLLER__/modifyPost">保存更改</button>
		</div>
	</div>
</form>

<!-- 图文素材列表 -->
<section id="news">
	<ul class="news-lists" id="news-lists"></ul>
</section>

<script type="text/javascript">
	var news_data = {$newsJSON};
</script>
<script type="text/javascript" src="__PUBLIC__/Style/My/Default/js/getNewsLists.js"></script>
<script type="text/javascript">
	$(function(){
		
		var type = $("#type-select option:selected").val(),
			pNum = 1,
			oText = $("#type-text"), 
			oNews = $("#type-news"), 
			oResult = $("#news-result ul"),
			news = $("#news"),
			selectId = {};
		
		if(type == "text"){
			oNews.hide();
			oText.show();
		}else if(type == "news"){
			oText.hide();
			oNews.show();
			oResult.show();
			news.show();
			$MoveTools.init();
		}
		
		$("#type-select").on("change", function(){
			var sel = $(this).val();
			if(sel == "text"){
				$("#type-news").hide();
				$("#type-text").show();
			}else if(sel == "news"){
				$("#type-text").hide();
				$("#type-news").show();
				$("#news").show();
				$MoveTools.init();
			}
		});

	});
</script>